package com.app.ctzoverseas.page.main.home

import com.android.base_network.extend.asResponse
import com.android.basemvvm.BaseViewModel
import com.blankj.utilcode.util.LogUtils
import com.cardetective.shopcar.network.model.GoodsAllModel
import com.cardetective.shopcar.network.model.UserInfoModel
import com.cardetective.shopcar.utils.InjectUtil
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.catch

class SortViewModel: BaseViewModel() {

    private val goodsRepo by lazy { InjectUtil.getGoodsRepo() }


    private val _categoryList = MutableSharedFlow<List<GoodsAllModel>>()
    val category: SharedFlow<List<GoodsAllModel>> = _categoryList


    fun getAllCategory() {
        launch {
            goodsRepo.getGoodsCategory("0")
                .asResponse()
                .catch {throwable->
                    LogUtils.e("getBannerList is error, msg: ${throwable.message}")
                    mBVOnExceptionListener?.onListener(-1,throwable.message.toString())
                }.collect(_categoryList)
        }
    }


}